package com.ws.service;


import com.ws.bean.Employee;
import com.ws.dao.EmployeeDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/*
    @Service：标明该类是service类
    该注解是由spring来读取。当spring框架读取到该注解时，
    会给该类创建一个对象，粗放到Spring IOC容器中。
    如果我们在controller中使用自动装配，需要该类型的对象时，会自动给装配的属性赋值
 */
@Service
public class EmployeeService {

    @Autowired
    private EmployeeDao employeeDao;

    public Employee login(String ename, String epass) {
        return employeeDao.login(ename, epass);
    }

    public List<Employee> findByPage(String estatus, int page, int size) {
        return employeeDao.findByPage(estatus, (page-1)*size, size);
    }

    public int totalLine(String estatus) {
        return employeeDao.totalLine(estatus);
    }

    public void addEmp(Employee employee) {
        employeeDao.addEmp(employee);
    }

    public Employee findByEid(String eid) {
        return employeeDao.findByEid(eid);
    }

    public void editUser(Employee employee) {
        employeeDao.editUser(employee);
    }

    public void updateEmp2(int estatus, int eid) {
        employeeDao.updateEmp2(estatus, eid);
    }

    public void updateEmp1(int estatus, int eid) {
        employeeDao.updateEmp1(estatus, eid);
    }

    public List<Employee> findByName(String realname, String estatus) {
        return employeeDao.findByName(realname, estatus);
    }

    public void updatePwd(int eid, String epass) {
        employeeDao.updatePwd(eid, epass);
    }

    public void updatePhoto(int eid, String photo) {
        employeeDao.updatePhoto(eid, photo);
    }

//    public int totalLine2(String realname, String estatus) {
//        return employeeDao.totalLine2(realname, estatus);
//    }
}
